﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoccerSimulator5000
{
    public class Finance
    {
        public int bankTotal { get; set; }
        public int totalExpensesPerInc { get; set; }
        public int totalIncomePerInc { get; set; }
        public int totalSalaries { get; set; }

        public BindingList<FinanceTransaction> transactions = new BindingList<FinanceTransaction>();
        

        public Stadium stadium = new Stadium();
        public Sponsor sponsor = new Sponsor();

        public Finance()
        {
            bankTotal = 1000000;
            totalExpensesPerInc = 0;
            totalIncomePerInc = 0;
            totalSalaries = 0;
        }

        public void UpdateExpences()
        {
            totalExpensesPerInc = stadium.totalExpencePerInc;
        }

        public void UpdateIncomes()
        {

            totalIncomePerInc = sponsor.payoutAmmount;

        }

        public void CalculateNewTotal()
        {
            int profit = totalIncomePerInc - totalExpensesPerInc;
            bankTotal += profit;
        }

        public void AddMatchIncome( int attendance )
        {
            bankTotal += stadium.ticketPrice * attendance;
            transactions.Add(new FinanceTransaction(Game.date, "Ticket sales", (stadium.ticketPrice * attendance)));

            bankTotal += stadium.facilitiesIncomePerAttendant * attendance;
            transactions.Add(new FinanceTransaction(Game.date, "Facilities", (stadium.facilitiesIncomePerAttendant * attendance)));
        }
    }
}
